<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%@ page import="com.conversationboard.model.*" %>
<%@ page import="com.conversationboard.config.*" %>
<%@ page import="com.conversationboard.controller.confirm.Confirm" %>
<%@ page import="java.security.Principal"%>

<%@ page pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8"%>

<%@page import="com.conversationboard.view.MainMenu"%>

<% 
    Principal principal = request.getUserPrincipal();
	User user = User.get(principal);
	request.setAttribute("user", user);
	
	String key = "";
	key = Confirm.getKey(request.getUserPrincipal().getName());
	
%>

<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
		<title>Edit Site Configuration</title>
		<link rel="stylesheet" type="text/css" href="<%=Configuration.getInstance().getRoot()%>/Stylesheets/<%=StyleSheets.getStyleSheetFileName(request.getCookies())%>"/>
	</head>

	<body>
	
		<%= MainMenu.display(principal) %>
	
		<div class="headingblock">
			<h1>Edit Site Configuration</h1>
		</div>

		<div class="mainblock">
		
			<form class="formsection" action="<%=Configuration.getInstance().getRoot()%>/Admin/AdminUpdateSiteConfigurationServlet" method="post">

				<p>Entries here affect the whole site installation. <strong>Incorrect usage can prevent the site from operating correctly</strong>, please exercise caution.</p>
							 	
			 	<%= key %>

			 	<label for="siteName"><strong>Site Name:</strong></label>
			 	<input name="siteName" class="smalltextbox" type="text" size="100" value="${config.siteName}"/><br /><br />

				<label for='allowUserBoardCreation'><strong>Allow User Board Creation:</strong></label>
				<input type='checkbox' name='allowUserBoardCreation' value='true' <c:if test="${config.allowUserBoardCreation}">CHECKED</c:if> /><br />

				<label for='allowHtmlPosts'><strong>Allow HTML Posts:</strong></label>
				<input type='checkbox' name='allowHtmlPosts' value='true' <c:if test="${config.allowHtmlPosts}">CHECKED</c:if> /><br />

				<label for='allowBlockRegistration'><strong>Allow Block Registration:</strong></label>
				<input type='checkbox' name='allowBlockRegistration' value='true' <c:if test="${config.allowBlockRegistration}">CHECKED</c:if> /><br />
				
				<label for="maxMessageSize"><strong>Max Message Size (characters):</strong></label>
			 	<input name="maxMessageSize" class="tinytextbox" type="text" size="100" value="${config.maxMessageSize}"/><br />
					
				<label for='checkForDuplicateMessages'><strong>Check For Duplicate Messages:</strong></label>
				<input type='checkbox' name='checkForDuplicateMessages' value='true' <c:if test="${config.checkForDuplicateMessages}">CHECKED</c:if> /><br />

				<label for='displayHumanTimes'><strong>Display Human Readable Times:</strong></label>
				<input type='checkbox' name='displayHumanTimes' value='true' <c:if test="${config.displayHumanTimes}">CHECKED</c:if> /><br />

				<label for='displayNumberOfRecentMessages'><strong>Display Number of Recent Messages:</strong></label>
				<input type='checkbox' name='displayNumberOfRecentMessages' value='true' <c:if test="${config.displayNumberOfRecentMessages}">CHECKED</c:if> /><br />

				<label for="oldestMessageCount"><strong>Oldest Message Count:</strong></label>
			 	<input name="oldestMessageCount" class="tinytextbox" type="text" size="100" value="${config.oldestMessageCount}"/><br />

				<label for="newestMessageCount"><strong>Newest Message Count:</strong></label>
			 	<input name="newestMessageCount" class="tinytextbox" type="text" size="100" value="${config.newestMessageCount}"/><br />

				<label for="maxThreadCacheEntries"><strong>Maximum Thread Cache Entries (requires restart):</strong></label>
			 	<input name="maxThreadCacheEntries" class="tinytextbox" type="text" size="100" value="${config.maxThreadCacheEntries}"/><br />

				<label for='captchaEnabled'><strong>Captcha Enabled:</strong></label>
				<input type='checkbox' name='captchaEnabled' value='true' <c:if test="${config.captchaEnabled}">CHECKED</c:if> /><br />

				<label for='testServer'><strong>Test Server:</strong></label>
				<input type='checkbox' name='testServer' value='true' <c:if test="${config.testServer}">CHECKED</c:if> /><br />

				<label for='storeDatabaseConnectionInfo'><strong>Store Database Connection Info:</strong></label>
				<input type='checkbox' name='storeDatabaseConnectionInfo' value='true' <c:if test="${config.storeDatabaseConnectionInfo}">CHECKED</c:if> /><br />

				<label for="maxImagesPerPost"><strong>Maximum Images Per Post:</strong></label>
			 	<input name="maxImagesPerPost" class="tinytextbox" type="text" size="100" value="${config.maxImagesPerPost}"/><br />

				<label for="threadIndexPath"><strong>Thread Index Path:</strong></label>
			 	<input name="threadIndexPath" class="smalltextbox" type="text" size="100" value="${config.threadIndexPath}"/><br />

				<label for="messageIndexPath"><strong>Message Index Path:</strong></label>
			 	<input name="messageIndexPath" class="smalltextbox" type="text" size="100" value="${config.messageIndexPath}"/><br />

				<label for="geoDatabasePath"><strong>Geo Database Path:</strong></label>
			 	<input name="geoDatabasePath" class="smalltextbox" type="text" size="100" value="${config.geoDatabasePath}"/><br />

				<label for='showLocationDataOnMessagesForSiteAdmins'><strong>Show Location Data on Messages for Site Admins:</strong></label>
				<input type='checkbox' name='showLocationDataOnMessagesForSiteAdmins' value='true' <c:if test="${config.showLocationDataOnMessagesForSiteAdmins}">CHECKED</c:if> /><br />

				<label for='supportSuggestBan'><strong>Support Flagged Posts:</strong></label>
				<input type='checkbox' name='supportSuggestBan' value='true' <c:if test="${config.supportSuggestBan}">CHECKED</c:if> /><br />

				<label for="banThreshold"><strong>Ban Threshold:</strong></label>
			 	<input name="banThreshold" class="tinytextbox" type="text" size="100" value="${config.banThreshold}"/><br />

				<label for="maxPollItems"><strong>Max Poll Items:</strong></label>
			 	<input name="maxPollItems" class="tinytextbox" type="text" size="100" value="${config.maxPollItems}"/><br />

				<label for='suggestSimilarThreads'><strong>Suggest Similar Threads:</strong></label>
				<input type='checkbox' name='suggestSimilarThreads' value='true' <c:if test="${config.suggestSimilarThreads}">CHECKED</c:if> /><br />

				<label for='displayAdminLogToUsers'><strong>Display Admin Log To Users:</strong></label>
				<input type='checkbox' name='displayAdminLogToUsers' value='true' <c:if test="${config.displayAdminLogToUsers}">CHECKED</c:if> /><br />

				<label for='displayAdminLogToSiteAdmins'><strong>Display Admin Log To Site Admins:</strong></label>
				<input type='checkbox' name='displayAdminLogToSiteAdmins' value='true' <c:if test="${config.displayAdminLogToSiteAdmins}">CHECKED</c:if> /><br />

				<label for='logSiteWideAdminActions'><strong>Log Sitewide Admin Actions:</strong></label>
				<input type='checkbox' name='logSiteWideAdminActions' value='true' <c:if test="${config.logSiteWideAdminActions}">CHECKED</c:if> /><br />

				<label for='allowChangeOfUserName'><strong>Allow Change of User Name:</strong></label>
				<input type='checkbox' name='allowChangeOfUserName' value='true' <c:if test="${config.allowChangeOfUserName}">CHECKED</c:if> /><br />

				<label for='adminsCanSeePictures'><strong>Admins Can See Pictures (only allow if confident about security of the site):</strong></label>
				<input type='checkbox' name='adminsCanSeePictures' value='true' <c:if test="${config.adminsCanSeePictures}">CHECKED</c:if> /><br />

				<label for='enableBlogView'><strong>Enable Blog View:</strong></label>
				<input type='checkbox' name='enableBlogView' value='true' <c:if test="${config.enableBlogView}">CHECKED</c:if> /><br />

				<label for='deleteOldUsers'><strong>Delete Old Users:</strong></label>
				<input type='checkbox' name='deleteOldUsers' value='true' <c:if test="${config.deleteOldUsers}">CHECKED</c:if> /><br />

				<br />

				<div class="formsectionlight">
					<label for='showPasswordImmediately'><strong>Show Password Immediately:</strong></label>
					<input type='checkbox' name='showPasswordImmediately' value='true' <c:if test="${config.showPasswordImmediately}">CHECKED</c:if> /><br />
	
					<label for='supportFileUploads'><strong>Support File Uploads:</strong></label>
					<input type='checkbox' name='supportFileUploads' value='true' <c:if test="${config.supportFileUploads}">CHECKED</c:if> /><br />

					<label for='onlySupportImageUploads'><strong>Only Support Image Uploads:</strong></label>
					<input type='checkbox' name='onlySupportImageUploads' value='true' <c:if test="${config.onlySupportImageUploads}">CHECKED</c:if> /><br />
	
					<label for="fileUploadRepository"><strong>File Upload Repository (a directory that Tomcat has access to, to place user uploaded files):</strong></label>
				 	<input name="fileUploadRepository" class="smalltextbox" type="text" size="100" value="${config.fileUploadRepository}"/><br />
	
					<label for='usersCanSeeTheirRecentPosts'><strong>Make link available for users to see their recent posts:</strong></label>
					<input type='checkbox' name='usersCanSeeTheirRecentPosts' value='true' <c:if test="${config.usersCanSeeTheirRecentPosts}">CHECKED</c:if> /><br />
	
					<label for='showNotWorksafeLinkForAdmins'><strong>Show Not Worksafe Link For Admins:</strong></label>
					<input type='checkbox' name='showNotWorksafeLinkForAdmins' value='true' <c:if test="${config.showNotWorksafeLinkForAdmins}">CHECKED</c:if> /><br />

					<label for='validateBBCode'><strong>Validate BB Code:</strong></label>
					<input type='checkbox' name='validateBBCode' value='true' <c:if test="${config.validateBBCode}">CHECKED</c:if> /><br />

					<label for='threadsPosts'><strong>Use Threads/Posts instead of Questions/Answers:</strong></label>
					<input type='checkbox' name='threadsPosts' value='true' <c:if test="${config.threadsPosts}">CHECKED</c:if> /><br />

					<label for="defaultStyleSheet"><strong>Default StyleSheet:</strong></label>
				 	<input name="defaultStyleSheet" class="smalltextbox" type="text" size="100" value="${config.defaultStyleSheet}"/><br />

					<label for='reportOnSockpuppets'><strong>Run Sockpuppet Report Nightly:</strong></label>
					<input type='checkbox' name='reportOnSockpuppets' value='true' <c:if test="${config.reportOnSockpuppets}">CHECKED</c:if> /><br />

					<label for='siteOpenOnStartup'><strong>Site Open on Startup:</strong></label>
					<input type='checkbox' name='siteOpenOnStartup' value='true' <c:if test="${config.siteOpenOnStartup}">CHECKED</c:if> /><br />

				</div>

				<br />

				<div class="formsectionlight">
				
					<p>Email Settings:</p>
				
					<label for='ssl'><strong>SSL:</strong></label>
					<input type='checkbox' name='ssl' value='true' <c:if test="${config.emailSsl}">CHECKED</c:if> /><br />

					<label for="smtpServer"><strong>SMTP Server:</strong></label>
				 	<input name="smtpServer" class="smalltextbox" type="text" size="100" value="${config.smtpServer}"/><br />

					<label for="port"><strong>Port:</strong></label>
				 	<input name="port" class="smalltextbox" type="text" size="100" value="${config.smtpPort}"/><br />

					<label for="loginId"><strong>Login ID:</strong></label>
				 	<input name="loginId" class="smalltextbox" type="text" size="100" value="${config.smtpServerLoginId}"/><br />
			
					<label for="password"><strong>Password:</strong></label>
				 	<input name="password" class="smalltextbox" type="text" size="100" value="${config.smtpServerPassword}"/><br />
				
				</div>

				<br /><br />
			 	<input type="submit" value="      Update Configuration      " />
			 	
			</form>
		</div>
		
		<!--<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>-->
		<!--<script type="text/javascript">_uacct = "UA-1148679-1";urchinTracker();</script>--> 
		
	</body>
	
</html>
